﻿<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">

    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />



    <link rel="stylesheet" href="../content/css/font.css">
    <link rel="stylesheet" href="../content/css/xadmin.css">
    <link rel="stylesheet" href="../content/plugin/bootstrap/css/bootstrap.min.css">
    <link rel='stylesheet' href='../content/plugin/bootstrap/css/style.css' />

    <script src="../content/js/jquery-1.10.2.min.js"></script>

    <script type="text/javascript" src="../content/js/xadmin.js"></script>
    <script type="text/javascript" src="../content/js/md5.min.js"></script>
    <script type="text/javascript" src="../content/js/cookie.js"></script>
    <script src="../content/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../content/plugin/FileUpload/css/jquery.fileupload.css" />




</head>

<body>
    <div id="app">
        <div class="x-nav">

            <span class="nav-header">
                <a href="">首页</a>>
                <a href="">发货配置</a>>

            </span>

        </div>
        <div class="x-body">


            <div class="content-inner">


                <!-- Forms Section-->
                <section class="forms">
                    <div class="container-fluid">
                        <div class="row">
                            <!-- Basic Form-->
                            <div class="col-lg-12">
                                <div class="card">

                                    <div class="card-body">

                                        <form class="form-horizontal">
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    配置
                                                </div>
                                                <div class="panel-body">
                                                    <div class="form-group">
                                                        <label for="firstname"
                                                            class="col-sm-2 control-label">用户名</label>
                                                        <div class="col-sm-10">
                                                            <input type="text" class="form-control"
                                                                style="width: 200px;float: left; "
                                                                v-model="addobj.phone" placeholder="">

                                                            <a @click="getdata" style="float: left;margin-left: 10px;"
                                                                class="btn btn-default">查询</a>

                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label for="firstname" class="col-sm-2 control-label">内容</label>
                                                        <div class="col-sm-10">
                                                            <textarea rows="2" name="img_desc_add"
                                                                ng-model="addobj.img_desc" cols="30" ng-model="value"
                                                                class="form-control" placeholder=""></textarea>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>




                                            <div class="form-group">
                                                <div class="col-sm-offset-2 col-sm-10">
                                                    <a @click="insert" class="btn btn-default">提交</a>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>



                        </div>
                    </div>
                </section>

            </div>
        </div>


    </div>





    </div>
    <link href="../content/plugin/sweetalert/sweetalert.css" rel="stylesheet">
    <script src="../content/plugin/sweetalert/sweetalert.min.js"></script>
    <script src="../content/plugin/bootstrap/js/bootstrap.min.js"></script>
    <script src="../content/js/vue2.js"></script>
    <script src="../content/js/vue-nav.js"></script>
    <script src="../content/js/config.js"></script>
    <link rel="stylesheet" href="../content/kindeditor/themes/default/default.css" />
    <script charset="utf-8" src="../content/kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="../content/kindeditor/lang/zh_CN.js"></script>

    <script>

        var editor_add;
        KindEditor.ready(function (K) {
            editor_add = K.create('textarea[name="img_desc_add"]', {
                width: '300px',
                allowFileManager: false,
                uploadJson: "/upload/file2"
            });
        });

        Array.prototype.remove = function (val) {
            var index = this.indexOf(val);
            if (index > -1) {
                this.splice(index, 1);
            }
        };
        var vm = new Vue({
            el: "#app",
            data: {
                all: 0,
                search: {
                    page: 1,
                    size: 10
                },
                imglist: [],
                brandlist: [],
                arrayData: [],
                allcount: 0,
                menulist: [],
                addobj: {
                    typename: "",
                    deduct_stock_type: "",
                    delivery_id: "0",
                    goods_status: "1",
                    brandname: "",
                    brandid: "0",
                    sales_initial: "0",
                    goods_sort: "0",
                    wxapp_id: json.mid

                },
                editobj: {},
                datalist: [],
                yunfeilist: [{ "id": "0", "name": "包邮" }, { "id": "1", "name": "不包邮" }],
                deductlist: [{ "id": 1, "name": "下单减库存" }, { "id": 2, "name": "付款减库存" }],
                statelist: [{ "id": "1", "name": "上架" }, { "id": "0", "name": "下架" }],
                typelist: [],
                typelist2: [],
                guigelist: [],
                guigeobj: {},
                temp: {}
            },
            components: {
                'vue-nav': Vnav
            },
            methods: {
                searchdata: function () {
                    this.search.page = 1;
                    this.getdata();
                },
                choosetype: function (uitem) {
                    this.addobj.typename = uitem.name;
                    this.addobj.category_id = uitem.id;
                },
                choosebrand: function (uitem) {
                    this.addobj.brandname = uitem.name;
                    this.addobj.brandid = uitem.id
                },
                chooseimage: function () {

                    x_admin_show('选择图片', '../components/imagelist.html', 800, 620)
                },
                add: function () {

                    this.guigelist.push(this.guigeobj);
                    this.guigeobj = {};

                },
                delitem: function (uitem) {
                    this.guigelist.remove(uitem)
                },
                addhang: function () {
                    if (this.datalist == null) {
                        this.datalist = [];
                    }
                    console.log("addhang", this.datalist);
                    var datalist = this.datalist;
                    datalist.push({});
                    this.datalist = datalist;
                },
                insert: function () {
                    var self = this;
                    this.addobj.config = editor_add.html();


                    $.post(apiurl + "/admin/user/config", this.addobj, function (data) {
                        if (data.status == 200) {
                            $("#addbox").modal('hide');
                            swal("success", "操作成功", "success");
                            setTimeout(() => {
                                window.location.reload();
                            }, 1000);
                        } else {
                            swal("系统提示", data.message, "error");
                        }

                    });
                },
                getdata: function () {

                    var self = this;
                    $.post(apiurl + "/admin/user/info", this.addobj, function (_result) {

                        if (_result.status == 200) {


                            editor_add.html(_result.data.config);
                        } else {
                            swal("系统提示", _result.message, "error");
                        }


                    });

                },
                gettype: function () {  //查询数据

                },
                gettype2: function () {  //活动分类

                    var self = this;
                    $.post(apiurl + "/admin/category/list", { type: 1 }, function (_result) {
                        console.log(_result);
                        self.typelist2 = _result.data;

                    });

                },
                gettype3: function () {  //查询数据

                    var self = this;
                    $.post(apiurl + "/admin/category/tree", { type: 3 }, function (_result) {
                        console.log(_result);
                        self.brandlist = _result.data;

                    });

                },
                chooseimg(uitem) {
                    this.temp = uitem;
                    x_admin_show('选择图片', '../components/image.html', 800, 620)
                },

            },
            created: function () {  //初始化事件里边去调用查询方法
                this.gettype("");
                this.gettype2();
                this.gettype3();



            }
        });

        function setimg(arr) {
            console.log("arr", arr);
            vm.$data.imglist = arr;
        }

        function setimage(imgurl) {
            console.log("imgurl", imgurl);
            vm.$data.temp.imgurl = imgurl;
            vm.$forceUpdate();
        }

    </script>
</body>

</html>